import logging
from redis import StrictRedis


class Config(object):
    DEBUG = True

    SECRET_KEY = "TOiRk0Cwyvm4C42NOGWBMLYVaXm4ZcvBqF+RKn2Wmr1DppOp53ZkQBumb89/klL3"

    # 添加数据库配置
    SQLALCHEMY_DATABASE_URI = "mysql://root:mysql@127.0.0.1:3306/information"
    SQLALCHEMY_TRACK_MODIFICATIONS = False

    # 此操作会在每次结束时(return后)自动执行 db.session.commit()操作
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True

    # redis 的配置
    REDIS_HOST = "127.0.0.1"
    REDIS_PORT = 6379
    # session 配置
    SESSION_TYPE = "redis"
    SESSION_USE_SINGNER = True
    SESSION_REDIS = StrictRedis(host=REDIS_HOST,port=REDIS_PORT)
    SESSION_PERMANENT = False
    PERMANENT_SESSION_LIFETIME = 86400 * 2

    LOG_LEVEL = logging.DEBUG


class DevelopmentConfig(Config):
    DEBUG = True


class ProductionConfig(Config):
    DEBUG = False
    SQLALCHEMY_DATABASE_URI = "mysql://root:mysql@127.0.0.1:3306/information"
    LOG_LEVEL = logging.WARNING


class TestingConfig(Config):
    DEBUG = True
    TESTING = True

config = {
    "development": DevelopmentConfig,
    "production": ProductionConfig,
    "testing": TestingConfig
}